<%@ page contentType="text/html; charset=UTF-8" import="java.util.*,com.pub.database.DBFunction,com.pub.tools.*"%>
<!-- 以下為DataView 共用設定 -->
<%com.pub.database.DataView DataView = new com.pub.database.DataView(ResourceBundle.getBundle("WEB_Config").getString("DB_ALIAS"),true, ResourceBundle.getBundle("WEB_Config").getString("SOURCE_CHARSET"), ResourceBundle.getBundle("WEB_Config").getString("TARGET_CHARSET"));%>
<jsp:useBean id="DataViewForm" scope="request" class="com.pub.database.DataViewForm"/>
<jsp:setProperty name="DataViewForm" property="submitMethod" value="POST"/>
<jsp:setProperty name="DataViewForm" property="pageRowCount" value="10"/>
<jsp:setProperty name="DataViewForm" property="nowPageNum"/>
<jsp:setProperty name="DataViewForm" property="dataViewAction"/>
<jsp:setProperty name="DataViewForm" property="filterCol"/>
<jsp:setProperty name="DataViewForm" property="filterValue"/>
<jsp:setProperty name="DataViewForm" property="dvOrderByFields"/>
<jsp:setProperty name="DataViewForm" property="dvOrderBySeq"/>
<!-- DataView 設定結束 -->
<%session.setAttribute("u_id","05227");//for test%>
<%
    StringBuffer stbSQL=new StringBuffer();
    StringBuffer stbPageActionURI=new StringBuffer("testDataView.jsp");

    DataViewForm.setFieldsList("b.dept_name,p.employee_no,p.employee_name_c," + PublicFunction.getSYSDATE("yyyy") + "-" + DBFunction.getDateToStrSyntax(DBFunction.getDBType(ResourceBundle.getBundle("WEB_Config").getString("DB_ALIAS")),"p.birth_date","yyyy") + ",p.birth_date,p.telephone_no,p.grad_school,p.major_code");
    DataViewForm.setTablesList("pnl_employee p,bas_dept b");
    DataViewForm.setSQLCondition("p.sex='F' and p.employee_st='A' and p.marriage='S' and p.dept_no=b.dept_no");
    DataViewForm.setOrderByFields("p.employee_no");
    DataViewForm.setOrderBySeq("asc");
    DataViewForm.setGroupBy(null);
    DataViewForm.setHaving(null);

    if(DataViewForm.getdvOrderByFields()!=null && DataViewForm.getdvOrderByFields().equals("年齡")){
      DataViewForm.setOrderByFields(DataViewForm.getOrderByFields()+",");
    }

    if(DataViewForm.getDataViewAction()!=null && DataViewForm.getDataViewAction().equals("filter") &&  PublicFunction.getTransCode(DataViewForm.getFilterCol(),"iso8859-1","utf8").equals("部門")){
      DataViewForm.setSQLCondition(DataViewForm.getSQLCondition() +  " and p.dept_name='" + DataViewForm.getFilterValue() + "'");
    }
    if(DataViewForm.getDataViewAction()!=null && DataViewForm.getDataViewAction().equals("filter") &&  PublicFunction.getTransCode(DataViewForm.getFilterCol(),"iso8859-1","utf8").equals("年齡")){
      DataViewForm.setSQLCondition(DataViewForm.getSQLCondition() + " and " + PublicFunction.getSYSDATE("yyyy") + "-" + DBFunction.getDateToStrSyntax(DBFunction.getDBType(ResourceBundle.getBundle("WEB_Config").getString("DB_ALIAS")),"p.birth_date","yyyy") + "=" + DataViewForm.getFilterValue());
    }

    //DataViewForm.setCountSQL("select count(*) from " + DataViewForm.getTablesList() + " where " + DataViewForm.getSQLCondition());
    //DataViewForm.setPrimaryField(null);
    DataViewForm.setPrimaryField("p.employee_no");

    boolean blnDebug=false;
    String strColRelation[][]=new String[9][];

    strColRelation[0]=new String[3];
    strColRelation[1]=new String[3];
    strColRelation[2]=new String[3];
    strColRelation[3]=new String[5];
    strColRelation[4]=new String[3];
    strColRelation[5]=new String[1];
    strColRelation[6]=new String[3];
    strColRelation[7]=new String[3];
    strColRelation[8]=new String[8];

    strColRelation[0][0]="'部門名稱'";
    strColRelation[0][1]="0";
    strColRelation[0][2]="WIDTH='10%'";		//???e??

    strColRelation[1][0]="'工號'";
    strColRelation[1][1]="0";
    strColRelation[1][2]="WIDTH='10%'";		//???e??

    strColRelation[2][0]="'姓名'";
    strColRelation[2][1]="0";
    strColRelation[2][2]="WIDTH='10%'";		//???e??

    strColRelation[3][0]="'年齡'";
    //strColRelation[3][1]="$({3}.equals(\"30\")&& ? \"0\" : \"INPUT\" )$";
    strColRelation[3][1]="INPUT";
    strColRelation[3][2]="WIDTH='15%'";
    strColRelation[3][3] = "<INPUT TYPE='TEXT' value="; //TYPE SUBMIT
    //VALUE 屬性務必放於最後面
    strColRelation[3][4] = "3"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住

    strColRelation[4][0]="'生日'";
    strColRelation[4][1]="0";
    strColRelation[4][2]="WIDTH='15%'";

    strColRelation[5][0]="N";
    //strColRelation[5][0]="'電話'";
    //strColRelation[5][1]="0";
    //strColRelation[5][2]="WIDTH='15%'";

    strColRelation[6][0]="'學校'";
    strColRelation[6][1]="0";
    strColRelation[6][2]="WIDTH='10%'";

    strColRelation[7][0]="'科系'";
    strColRelation[7][1]="0";
    strColRelation[7][2]="WIDTH='15%'";

    strColRelation[8][0]="'電話'";
    //strColRelation[3][1]="$({3}.equals(\"30\") ? \"0\" : \"INPUT\" )$";
    strColRelation[8][1]="LINK";
    strColRelation[8][2]="WIDTH='15%'";
    strColRelation[8][3] = "<a href="; //TYPE SUBMIT
    //VALUE 屬性務必放於最後面
    strColRelation[8][4] = "5"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住
    strColRelation[8][5] = "'#'"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住
    strColRelation[8][6] = "tel="; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住
    strColRelation[8][7] = "5"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住



    DataViewForm.setColRelation(strColRelation);//將欄位相關設定殖入ActionForm
    //DataViewForm.setTableDataTrHtml("onmouseover=\"this.className='td_content_ov" +
    //                                "er'\" onmouseout=\"this.className='td_content'\"");//設定每筆TR的Html
    DataViewForm.setTableDataTrHtml("id='tr%sn%' name='tr%sn%'");
    DataViewForm.setTableHeaderHtml("");
    DataViewForm.setPageBtnOnTop(true);         //將button and rows info 秀在頂端
    DataViewForm.setPageBtnOnButtom(false);      //將button and rows info 秀在底端
    DataViewForm.setFilterShow(true);           //是否要秀出過濾選擇欄位
    DataViewForm.setJumpPageShow(true);         //是否要秀出跳頁下拉式選單
    DataViewForm.setRowsInfoShow(true);         //是否要秀出筆數資訊
    DataViewForm.setRowPageShow(true);          //是否要秀出每頁筆數控制欄
    DataViewForm.setExcelShow(false);           //是否要秀出轉Excel button
    DataViewForm.setOrderEnable(true);          //是否要提供排序點選功能
    DataViewForm.setJumpPageButtonShow(true);   //是否要秀出上下頁按鈕
    DataViewForm.setShowHeaderWhenNoData(false);

	//設定上一頁與下一頁按鈕的form action(通常為母頁即本頁)
    DataViewForm.setPageActionURI(stbPageActionURI.toString());
%>
<script language="javascript" type="">
  function setDataView(){
    for(i=0;i<document.DataViewForm.elements.length;i++){
      if (document.DataViewForm.elements[i].type=='text' && (document.DataViewForm.elements[i].name.substring(0,6)=='empage')){
        //alert(document.DataViewForm.elements[i].name + '==>' + (document.DataViewForm.elements[i].name.substring(6)));
        if(document.all.item('empage' + document.DataViewForm.elements[i].name.substring(6)).value<=27){
          document.all.item('tr' + document.DataViewForm.elements[i].name.substring(6)).className='td_content_over';
        }
      }
    }
  }
</script>
<html>
<head>
<title>testDataView</title>
<LINK HREF="/PUBPAGE/general/workflow.css" REL="stylesheet" TYPE="text/css">
</head>
<body bgcolor="#ffffff" onload="javascript:setDataView();">
  <base target='_self'/>
  <%DataView.OutputDataView(DataViewForm,pageContext);%>
</body>
</html>
